package exercise;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @classname:Main
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/10 20:58
 * @version: 0.1
 * @since:1.8
 */
public class Main {
    //转换格式
    private static final String PATTERN = "yyyy-MM-dd HH:mm:ss";

    public static void main(String[] args) {
        //时间字符串
        String strTime = "2020-12-12 12:00:00";
        //创建DateTimeFormatter实例传入PATTERN
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(PATTERN);
        //利用LocalDateTime的parese方法转换格式
        LocalDateTime date = LocalDateTime.parse(strTime, dateTimeFormatter);
        //输出结果
        System.out.println(date);
    }
    //结果
    //2020-12-12T12:00
}
